package com.albert.WSMqtt;

import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.IMqttToken;
import org.eclipse.paho.client.mqttv3.MqttMessage;

public interface WSMqttCallback {
    //第一步连接上服务器
    default void connectComplete(boolean reconnect, String serverURI) {};
    default void connectionLost(Throwable cause) {};

    //第二步Mqtt连接上
    void mqttConnectSuccess(IMqttToken asyncActionToken);
    void mqttConnectFailure(IMqttToken asyncActionToken, Throwable exception); // 默认空实现

    //第三步Mqtt注册topic
    default void mqttSubscribeSuccess(IMqttToken asyncActionToken) {};
    default void mqttSubscribeFailure(IMqttToken asyncActionToken, Throwable exception) {}; // 默认空实现

    //Mqtt注销topic
    default void mqttUnsubscribeSuccess(IMqttToken asyncActionToken) {};
    default void mqttUnsubscribeFailure(IMqttToken asyncActionToken, Throwable exception) {}; // 默认空实现

    //Mqtt发消息
    default void mqttPublishSuccess(IMqttToken asyncActionToken) {};;
    default void mqttPublishFailure(IMqttToken asyncActionToken, Throwable exception) {}; // 默认空实现
    default void deliveryComplete(IMqttDeliveryToken token) {};

    //收到消息
    default void messageArrived(String topic, MqttMessage message) {};

}
